const buildConfig = require('./config')
const argv = require('minimist')(process.argv.slice(2));
process.env.NODE_ENV = (argv.mode ? argv.mode : (argv._ === 'build' ? 'production' : 'dev'));
let config = buildConfig[process.env.NODE_ENV] || buildConfig.default
module.exports = {
  outputDir: config.outputDir,
  publicPath: config.publicPath,
  devServer: {
    host: config.host,
    port: config.port,
    proxy: {
      [config.useProxyUrl]: {
        target: config.apiRealUrl,
        changeOrigin: true,
        pathRewrite: {
          [`^${config.useProxyUrl}`]: ''
        }
      }
    }
  },
  chainWebpack: config => {
    config.module.rule('images').use('url-loader').loader('url-loader').tap(options => {return Object.assign(options, { limit: 5 })});
  }
};
